
import java.util.*;
import p.*;

public class TestCommon {
	
	private static char []letters={'A','B','C','D','E','F','G','H','I',
								   'J','K','L','M','N','O','P','Q','R',
								   'S','T','U','V','W','X','Y','Z'};
	private static Random rnd=new Random();
	
	private static int count=0;
	private static long dayCount=0;
	
	public static String getRandomStr(int len){
		StringBuffer str=new StringBuffer();
		for(int i=0;i < len;i++)
			str.append(letters[rnd.nextInt(26)]);
		return str.toString();
	}
	
	public static String getStringIncre(){
		return "Feed String:"+new Integer(count++);
	}
	
	public static void clrCounter(int to){count=to;}
	
	public static Random getRandom(){
		return rnd;
	}
	
	public static Date getRandomDate(){
		return new Date(Math.abs(rnd.nextInt(10000)));
	}
	
	public static void setDataCounterTo(long to){dayCount=to;}
	
	public static Date getDateIncre(){
		Date ret=new Date(dayCount);
		dayCount+=3600*24;
		return ret;
	}
	
	public static Address getRandomAddress(){
		Address add=new Address(getRandomStr(10),
				           getRandomStr(10),
				           getRandomStr(10),
				           getRandomStr(10));
		System.out.println("Address created: "+add.toString());
		return add;
	}
	
	public static DocType getDocType(){
		String str=getRandomStr(10);
		DocType.create(str, getRandomStr(10));
		DocType dt=DocType.get(str);
		if(dt == null)
			System.out.println("no dt found");
		System.out.println("DocType created: "+dt.toString());
		return dt;
	}
	
	public static TelNumber getTelNumber(){
		TelNumber tn=new TelNumber(rnd.nextLong(),rnd.nextLong(),rnd.nextLong(),rnd.nextLong());
		System.out.println("TelNumber created: "+tn.toString());
		return tn;
	}
	
	public static Unit getUnit(){
		switch (rnd.nextInt(2)){
		case 0:
			return Unit.getChinese();
		case 1:
			return Unit.getEuro();
		default:
			return Unit.getUs();
		}
	}
	
	public static String toStringMoney(Pair p){
		return p.getFirst().toString()+"(measured by:"+p.getSecond().toString()+")";
	}
}
